package com.excellence.service.impl;

import com.excellence.pojo.Massif;
import com.excellence.mapper.MassifMapper;
import com.excellence.service.MassifService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * (Massif)表服务实现类
 *
 * @author makejava
 * @since 2024-04-28 09:46:54
 */
@Service("massifService")
public class MassifServiceImpl implements MassifService {
    @Autowired
    private MassifMapper massifMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param massifId 主键
     * @return 实例对象
     */
    @Override
    public Massif queryById(Integer massifId) {
        return massifMapper.queryById(massifId);
    }


    /**
     * 新增数据
     *
     * @param massif 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(Massif massif) {
        massif.setDeleted((short) 0);
        massif.setCreateTime(new Date());
        return massifMapper.insert(massif);
    }

    /**
     * 修改数据
     *
     * @param massif 实例对象
     * @return 实例对象
     */
    @Override
    public Massif update(Massif massif) {
        massifMapper.update(massif);
        return this.queryById(massif.getMassifId());
    }

    /**
     * 通过主键删除数据
     *
     * @return 是否成功
     */
    @Override
    public int deleteById(Massif massif) {
        massif.setDeleted((short) 1);
        return massifMapper.update(massif);
    }

    @Override
    public List<Massif> selectAll(Integer userId) {
        return massifMapper.selectAll(userId);
    }
}
